Repository navigation
Answer A2A 1.0 JSON-RPC method names and enums; security schemes on the agent card - #66
Merged
Merged
Conversation
…ow a caller authenticates The card says protocolVersion 1.0, but the server only knew the 0.3 method names (message/stream) and wrote enums in lower case (working, agent). A 1.0 client such as @a2a-js/sdk 1.x sends SendStreamingMessage and reads TASK_STATE_WORKING and ROLE_AGENT, so it could not talk to a fasta2a agent. - fasta2a.jsonrpc_v1: SendMessage, SendStreamingMessage, GetTask, CancelTask, SubscribeToTask and ListTasks are read as the methods they name, with their enums (ROLE_*, TASK_STATE_*) read as this library's; tenant is dropped, and returnImmediately is dropped with acceptedOutputModes defaulted. The answer, JSON or event stream, is written with 1.0's enums. A request with the names this library always used is answered exactly as before. - FastA2A(security_schemes=..., security_requirements=...): the card says how a caller authenticates. It is said, not enforced: a server checks it in its own middleware. - tests/test_jsonrpc_v1.py.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Enum conversion can corrupt application payloads and leaves valid v1 task-status filters unnormalized.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds A2A 1.0 client compatibility to FastA2A while preserving legacy method handling.
Changes:
- Translates v1 method names and enums for JSON and streaming responses.
- Adds declarative authentication settings to the agent card; enforcement remains middleware-controlled.
- Adds six tests covering compatibility and security declarations.
| File | Description |
|---|---|
| tests/test_jsonrpc_v1.py | Tests v1 translation, legacy behavior, and security declarations. |
| fasta2a/jsonrpc_v1.py | Implements request and response translation. |
| fasta2a/applications.py | Integrates translation and agent-card security settings. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+71
to
+89
| else: | ||
| out[key] = _enums_from_v1(item) | ||
| return out | ||
| if isinstance(value, list): | ||
| return [_enums_from_v1(item) for item in _array(value)] | ||
| return value | ||
|
|
||
|
|
||
| def to_v1(value: Any) -> Any: | ||
| """A result of this server with its enums as A2A 1.0 writes them: `ROLE_*` and `TASK_STATE_*`.""" | ||
| if isinstance(value, dict): | ||
| out: dict[str, Any] = {} | ||
| for key, item in _object(value).items(): | ||
| if key == 'role' and isinstance(item, str): | ||
| out[key] = _ROLE_TO_V1.get(item, item) | ||
| elif key == 'state' and isinstance(item, str): | ||
| out[key] = _STATE_TO_V1.get(item, item) | ||
| else: | ||
| out[key] = to_v1(item) |
| method = envelope.get('method') | ||
| if not isinstance(method, str) or method not in V1_METHODS: | ||
| return None | ||
| params = _object(_enums_from_v1(dict(_object(envelope.get('params') or {})))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The agent card says
protocolVersion: "1.0", but the server only answered the 0.3 method names (message/stream) and wrote enums in lower case (working,agent). A 1.0 client such as@a2a-js/sdk1.x sendsSendStreamingMessageand readsTASK_STATE_WORKING/ROLE_AGENT, so it could not talk to a fasta2a agent.fasta2a.jsonrpc_v1:SendMessage,SendStreamingMessage,GetTask,CancelTask,SubscribeToTask,ListTasksare read as the methods they name, their enums (ROLE_*,TASK_STATE_*) read as this library's;tenantis dropped,returnImmediatelydropped withacceptedOutputModesdefaulted. The answer (JSON or SSE) is written with 1.0 enums. Requests with the existing names are answered exactly as before.FastA2A(security_schemes=..., security_requirements=...): the card says how a caller authenticates (declared, not enforced: usemiddleware).tests/test_jsonrpc_v1.py(6).Locally on a fresh 3.12 env: ruff format/check clean, pyright 0 errors, pytest 43 passed.
Needed by agent-runtimes' team-of-applications example (a browser app on
@a2a-js/sdk1.3 calling an app served with fasta2a). Release as 2.1.0 after merge.